/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package aptech.JavaXML.DOMValidator;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

/**
 *
 * @author thanhtq
 */
public class Answer{

    private String id;
    private String option;
    private String quesId;
    private String rate;

    public String getRate() {
        return rate;
    }

    public void setRate(String rate) {
        this.rate = rate;
    }

    
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getOption() {
        return option;
    }

    public void setOption(String option) {
        this.option = option;
    }

    public String getQuesId() {
        return quesId;
    }

    public void setQuesId(String quesId) {
        this.quesId = quesId;
    }

    @Override
    public String toString() {
        return "."+option;
    }

    public void createAnswerElement(Document doc) throws Exception{
        try{
            Element categoryElement = doc.createElement("answer");

            categoryElement.setAttribute("id", id);
            Element contentElement = doc.createElement("option");
            contentElement.setTextContent(option);
            Element commentElement = doc.createElement("QuesID");
            commentElement.setTextContent(quesId);
            categoryElement.appendChild(contentElement);
            categoryElement.appendChild(commentElement);
            doc.getDocumentElement().appendChild(categoryElement);
        }
        catch(Exception ex){
            throw ex;
        }

    }

    
}
